#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1000000 + 1;
int a[maxn];
bool bin[maxn][32];
int po[32] = {0};
int t[maxn] = {0};
int b[maxn];
int n;

int main()
{
    long long s;
    cin >> n;
    s = 0;
    po[0] = 1;
    for(int i = 1; i < 32; i ++)
        po[i] = po[i-1] * 2;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
        t[a[i]] ++;
        s += a[i];
    }
    int k = 0;
    for(int i = 0; i < maxn; i ++)
    {
        for(int j = 0; j < t[i]; j ++)
            b[k ++] = i;
    }

    string str;
    cin >> str;
    if(str == "+")
    {
        cout << s * n * 2 << endl;
    }
    else if(str == "-")
    {
        cout << 0 << endl;
    }
    else if(str == "*")
    {
        cout << s * s << endl;
    }
    else if(str == "/")
    {
        double d = s, total = 0;
        for(int i = 0; i < n; i ++)
            total += d / a[i];
        long long x = total;
        cout << x << endl;
    }
    else if(str == "and")
    {

        int s[21] = {0};
        for(int i = 0; i < n; i ++)
        {
            int xn = 0;
            int p = a[i];
            while(p)
            {
                s[xn ++] += p % 2;
                p /= 2;
            }
        }
        long long total = 0;
        for(int j = 0; j < 20; j ++)
        {
            total += s[j] * s[j] * po[j];
        }
        cout << total << endl;

    }
    else if(str == "or")
    {

        int s[21] = {0};
        for(int i = 0; i < n; i ++)
        {
            int xn = 0;
            int p = a[i];
            while(p)
            {
                s[xn ++] += p % 2;
                p /= 2;
            }
        }
        long long total = 0;
        for(int j = 0; j < 20; j ++)
        {
            total += s[j] * (n - s[j]) * po[j] * 2 + s[j] * s[j] * po[j];
        }
        cout << total << endl;
    }
    else if(str == "xor")
    {
        int s[21] = {0};
        for(int i = 0; i < n; i ++)
        {
            int xn = 0;
            int p = a[i];
            while(p)
            {
                s[xn ++] += p % 2;
                p /= 2;
            }
        }
        long long total = 0;
        for(int j = 0; j < 20; j ++)
        {
            total += s[j] * (n - s[j]) * po[j] * 2;
        }
        cout << total << endl;
    }
    else if(str == ">")
    {
        long long total = 0, pres = 0;
        for(int i = 0; i < maxn; i ++)
        {
            total += t[i] * pres;
            pres += t[i];
        }
        cout << total << endl;
    }
    else if(str == ">=")
    {
        long long total = 0, pres = 0;
        for(int i = 0; i < maxn; i ++)
        {
            pres += t[i];
            total += t[i] * pres;
        }
        cout << total << endl;
        //long long total = 0;
    }
    else if(str == "L")
    {
        long long total = 0;
        for(int i = 0; i < n - 1; i ++)
        {
              total += (i + 1) * (b[i+1] - b[i]) * (n - i - 1);
        }
        total *= 2;
        cout << total << endl;/*
        total = 0;
        for(int i = 0; i < n; i ++)
        for(int j = 0; j < n; j ++)
            total += abs(a[i] - a[j]);
        cout << total << endl;*/
    }
    return 0;
}
